package com.naiterui.ehp.bs.b2c.order.service.impl.logistics;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import com.naiterui.ehp.bp.utils.context.SpringContextHolder;
import com.naiterui.ehp.bs.b2c.order.bo.LogisticsInfoBO;
import com.naiterui.ehp.bs.b2c.order.service.ILogisticsTraceService;

import lombok.extern.slf4j.Slf4j;

@Slf4j
@Service("defaultLogisticsTraceService")
public class DefaultLogisticsTraceServiceImpl implements ILogisticsTraceService {

    @Value("${kuaidi100.enable}")
    private Boolean enable;

    @Override
    public LogisticsInfoBO getTrace(String deliveryId, String companyCode, String phone) {
        // if ("shunfeng".equals(companyCode)) {
        // return this.getLogisticsTraceService(companyCode).getTrace(deliveryId);
        // }
        // 顺丰之外其余的所有快递单都走快递100(enable属性弃用)
        return this.getLogisticsTraceService("kudi100").getTrace(deliveryId, companyCode, phone);
    }

    private AbstractLogisticsTraceService getLogisticsTraceService(String logisticsCompanyCode) {
        return SpringContextHolder.getBean(logisticsCompanyCode, AbstractLogisticsTraceService.class);
    }

}
